package cn.itcast.day04;

public class text01 {

    public static void main(String[] args) {

        int[] arr = {1,2,3};
        String str = arrayToString(arr);
        System.out.println(str);
    }

    //定义一个方法将数组转为字符串{1,2,3}-->[word1#word2#word3]
    public static String arrayToString(int[] arr) {
        String str = "[";
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                str += "word" + arr[i] + "]";
            }else {
                str += "word" + arr[i] + "#";
            }
        }
        return str;
    }
}
